<?php
namespace app\app\controller;

use app\common\model\Article;

class Product extends Base
{

    public function index()
    {
        try{
            $hot = \app\common\model\Product::getList([]);
            if($hot['code'] == 1){
                exception($hot['msg']);
            }
            return $this->succeed('操作成功',['data'=>$hot['data']]);
        }catch (\Exception $e){
            return $this->fail($e->getMessage());
        }

    }

    public function detail(){
        try{
            $input = input('post.',null,'trim');
            $product = \app\common\model\Product::get($input['id']);
            if(empty($product)){
                exception('产品不存在');
            }
            return $this->succeed('操作成功',['data'=>$product]);
        }catch (\Exception $e){
            return $this->fail($e->getMessage());
        }
    }


}
